home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!austern
- From: Eugene Lazutkin <eugene@int.com>
- Newsgroups: comp.std.c++
- Subject: RE: An STL helper -- and template and type shenanigans
- Date: 31 Jan 1996 12:04:06 PST
- Organization: -
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <01BAEFD6.AD7E8620@dino.int.com>
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: Wed, 31 Jan 1996 12:21:40 -0600
- Encoding: 73 TEXT
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMQ/LTEy4NqrwXLNJAQGbEwIAjtbc+0EEpF0ZdqT0geQ5wTtzLX2/X4Do
- I7R/2LWIXQKXhrunvl7avesYs5jV1IyzvdBVh4PaAMCrvuAYOtYQYQ==
- =XkBh
- Originator: austern@isolde.mti.sgi.com
-
- On Monday, January 29, 1996 12:50 PM, fjh@munta.cs.mu.OZ.AU (Fergus Henderson) wrote:
- > esap@cs.tut.fi (Pulkkinen Esa) writes:
- >
- > >template <class T>
- > >class type_dereferencer<T*>
- > >{
- > >public:
- > > typedef T base_type;
- > >};
- > [...]
- > >And if typedef templates were allowed, you could use a slightly better
- > >syntax:
- > >
- > >template <class T>
- > >typedef type_dereferencer<T>::base_type type_dereference;
-
- Don't forget another point: YOU CAN'T INHERIT CONSTRUCTORS. In fact
-
- 1) class B : public A {};
-
- and
-
- 2) typedef A B;
-
- is not the same if you have non-default constructors in the class A.
- You have to put some constructors in a 1st example, like
-
- class B : public A
- {
- public:
- B( T1 x ) : A(x) {}
- B( T2 x ) : A(x) {}
- B( T1 x, T2 y ) : A(x,y) {}
- /* ... other constructors ... */
- B() : A() {}
- B( const A& a ) : A(a) {}
- };
-
- if you are going to emulate 2nd. To me the typedef templates would solve
- this problem easily and effectifely.
-
- > Can someone please remind me why we decided not to allow typedef templates?
-
- Yeah, why?
-
- > It certainly seems like a bad idea to force everyone to use this silly
- > obfuscation for what is obviously a common need.
-
- I wrote several wrappers like written above for my application which uses STL.
- When I change the set of possible constructors of the base class I need
- find all appropriate wrappers and correct them too. I have to keep my code
- up-to-date manually.
-
- Why do I use wrappers? Just small example: vector< auto_ptr< T > >
- (or list< auto_ptr< T > >). I f you tried it, you'd discover that STL
- (I use ObjectSpace's implementation) uses copy-ctor with a const parameter
- and auto_ptr doesn't define it. The same for a copy-op. Additionally
- my VC++ 4.0 tries to instantiate some unused methods (?) and of course doesn't
- find less-operator. That's why I need wrappers.
-
- BTW, how come that auto_ptr from Standard C++ Library is incompatible with
- vector<>, list<> and other STL containers from the same source? Or maybe I
- have incorrect implementation?
-
- > Fergus Henderson WWW: http://www.cs.mu.oz.au/~fjh
- > fjh@cs.mu.oz.au PGP: finger fjh@128.250.37.3
-
- Thanks in advance
-
-
-
- Eugene Lazutkin
- eugene@int.com
- ---
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
- is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
-